<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="box">
        <input type="password" v-model="mytext">
        {{mytext}}

        <textarea v-model="mytext"></textarea>

        <h2>多选-checkbox</h2>
        <!-- v-model 对于表单绑定的用法-->
        <input type="checkbox" v-model="checkGroup" value="vue">vue
        <input type="checkbox" v-model="checkGroup" value="react">react
        <input type="checkbox" v-model="checkGroup" value="juquery">juquery
        <button @click="hanleSubmit()">提交</button>

        <!-- 针对一个绑定事件时，不需要像表单式的绑定数组，而是绑定布尔值 -->
        <h2>checkbox-记住用户名</h2>
        <input type="checkbox" v-model="isRem">记住用户名
        <button @click="handleLogin()">登陆</button>

        <h2>radio - 单选</h2>
        <input type="radio" v-model="favorlang" value="vue" name="favor">vue
        <input type="radio" v-model="favorlang" value="react" name="favor">react
        <input type="radio" v-model="favorlang" value="juquery" name="favor">juquery
        <button @click="hanleSelect()">单选提交</button>
        
    </div>

    <script>
        var vm = new Vue ({
            el:"#box",
            data: {
                mytext:'',
                checkGroup:[],
                isRem:false,
                favorlang:"vue"     //设置初始值
            },
            methods:{
                hanleSubmit(){
                    console.log('提交', this.checkGroup)
                }, 
                handleLogin(){
                    console.log('登陆',this.isRem)
                }, 
                hanleSelect(){
                    console.log('this. favorlang') //获取favorlang上用户输入的值，并同步修改
                }
            }
        })
    </script>
</body>
</html>